/******************************************************************************/
/*  GO! 2010                                                                  */
/*  PROJECT "SmartBUG Demo"                                                   */
/*  SOFT: S. Maslyakov, rusoil.9@gmail.com                                    */
/*                                                                            */
/*  Revision:     1.15                                                        */
/*  Date:         2011/08/15 00:29:33                                         */
/******************************************************************************/

#include "data_types.h"
#include "global_def.h"
#include "Core\core.h"
#include "Relay\relay.h"
#include "Din\din.h"
#include "Ain\ain.h"
#include "Device\device.h"
#include "Ds1820\ds1820.h"
#include "I2C\i2c.h"
#include "Ad7814arm\ad7814arm.h"
#include "At25df\at25df.h"
#include "Temp\temp.h"
#include "Led\led.h"
#include "Heater\heater.h"
#include "Rfile\rfile.h"
#include "Mlog\mlog.h"
#include "Usb\usb.h"
#include "Mb_master\mb_master.h"
#include "Modem\modem.h"
#include "Setpoint\setpoint.h"
#include "Packet\packet.h"
#include "Smartbug\smartbug.h"
#include "TNKernel\tn.h"




/******************************************************************************/
/*      Init static members                                                   */
/******************************************************************************/
__TOOLS_RELAY RELAY::m_tools;
__SETT_RELAY  RELAY::m_sett[eREL_END];

uint8_t RFILE::m_rfile[RFILE_RAM_SIZE];

uint32_t MLOG::m_timer[MLOG_QNT_LOGS - 1];
uint32_t MLOG::m_flgSendState;

__TOOLS_DIN DIN::m_tools[eDIN_END];
__SETT_DIN  DIN::m_sett[eDIN_END];

__TOOLS_AIN AIN::m_tools[eAIN_END];
__DATA_AIN  AIN::m_data;

__GLOBAL_TIMER_DEVICE DEVICE::m_timers;
__SETTINGS_DEVICE     DEVICE::m_devSett;

uint8_t DS1820::m_buff[9];

__DATA_TEMP  TEMP::m_data;
__TOOLS_TEMP TEMP::m_tools[eTEMP_END];
__FLG_TEMP   TEMP::m_flg;

sint16_t AD7814ARM::m_lastTemp = 0;

__LED_TOOL LED::m_ledData;
__LED_TOOL LED::m_ledStatus;
__LED_TOOL LED::m_ledGsm;

uint32_t HEATER::m_heaterBlankTimer;

bool_t  AT25DF::m_isFlashOk;
uint8_t AT25DF::m_familyCode;
uint8_t AT25DF::m_densityCode;

__UART_TOOLS UART1::uart;
__UART_TOOLS UART2::uart;

__USB_RX_BUFF_TOOLS      USB::m_rxBuff;
__USB_TX_BUFF_TOOLS      USB::m_txBuff;
__USB_BULK_TX_BUFF_TOOLS USB::m_bulkTxBuff;
__USB_TOOLS              USB::m_tools;
__USB_SETUP_PACKET       USB::m_setup;
__USB_SETUP_PACKET       USB::m_setupData;
__CDC_PORT_SETT          USB::m_cdcPortSett;
__CDC_PORT_STATE         USB::m_cdcPortState;

__MD_STATUS_FLG    MODEM::m_mdFlg;
__MD_INFO          MODEM::m_mdInfo;
__MD_SIM_INFO      MODEM::m_simInfo;
__MD_PARSING_TOOLS MODEM::m_mdPars;
__MD_TCP_TOOLS     MODEM::m_tcpTools;

__MB_ANSW_READY_DATA * MB_MASTER::m_pAnsw;
__MB_QUERY_TOOLS       MB_MASTER::m_query;

__TOOLS_SETPOINT SETPOINT::m_tools[MEM_SETPOINT_NUM];

uint32_t PACKET::m_timer;

/******************************************************************************/
/*                                                                            */
/******************************************************************************/


/******************************************************************************/
/*                                                                            */
/*      MAIN                                                                  */
/*                                                                            */
/******************************************************************************/
void main()
{
    CORE::Init_Core();

    SMARTBUG::Init_Device();

    //DEBUG_PRINTF("\r\nStart...\r\n");

    // Run RTOS
    tn_start_system();
}
/******************************************************************************/
/*                                                                            */
/*      THE END                                                               */
/*                                                                            */
/******************************************************************************/